package file;

import java.io.File;

public class ListFilesDemo {
    public static void main(String[] args) {
        File dir = new File(".");
        if (dir.isDirectory()) {//isFlie()判断是否是文件或目录
            File[] subs =dir.listFiles();
            System.out.println("当前目录下共有"+dir.length()+"个子项");
            for (File sub:subs){
                System.out.println(sub.getName());//输出每个子项的名称
            }

        }
    }
}

